package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.ui.contract.TaskingContract
import com.baizan.daka.mvp.model.MyTaskModel
import com.baizan.daka.mvp.model.NewsModel
import com.baizan.daka.mvp.model.bean.NewsDetailBean
import com.baizan.daka.mvp.model.bean.NewsInfoBean
import com.baizan.daka.mvp.model.bean.TaskInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.NewsContract
import com.baizan.daka.ui.contract.NewsDesContract

class NewsDesPresenter(val mView: NewsDesContract.View) : BasePresenter(),
    NewsDesContract.Presenter {
    val newsModel: NewsModel by lazy { NewsModel() }

    override fun loadNewsDes(id: Long) {
        mView.showLoadingDialog()
        newsModel.loadNewsDetail(id)
            .subscribe(object :CommonSubscriber<NewsDetailBean>(compositeDisposable){
                override fun onCallNext(t: NewsDetailBean?) {
                    mView.loadNewsDesSuccess(t!!)
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                   mView.hideLoadingDialog()
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }

            })
    }


}